package com.hsl.study.config;


import com.hsl.study.interceptor.IdempotentInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 在 Spring Boot 配置文件类中，添加拦截器配置
 * @auther hsl
 * @create 2024-12-28 16:43
 */
@Configuration
public class WebConfig implements WebMvcConfigurer
{
    @Resource
    private IdempotentInterceptor idempotentInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(idempotentInterceptor).addPathPatterns("/**"); // 拦截所有接口
    }
}
